<template>
	<view class="content" style="background-color: #fff;">
		<u-navbar leftIconColor="white" bgColor="#4399FF" scrollable=false titleStyle="font-size:40rpx;color:white"
			:placeholder='true' title="找品牌" :autoBack="true">
		</u-navbar>
		<view class="top">
			<u-input prefixIcon="search" prefixIconStyle="color:#999999;" placeholder="搜索品牌旗舰店"
				customStyle="height:88rpx;padding:0rpx 20rpx;background-color: #f5f5f5; color:#999999;"
				border="surround" v-model="value" @change="change" :clearable='true' @clear="value='';change()">
			</u-input>
			<view class="nav flexJBC">
				<view class="" style="width: 90%;overflow: hidden;" @click="state=false,ismodel=false">
					<u-tabs activeStyle="color:white;" inactiveStyle="color:#C7E0FF;" :list="list1" @click="click">
					</u-tabs>
				</view>
				<image @click="isshow()" src="/static/images/mine/menu.png" style="width: 48rpx;height: 48rpx;" mode="">
				</image>
			</view>
		</view>
		<view class="container" style="position: relative;">
			<!-- nav -->
			<view class="shop_2" v-show="!state">
				<view class="li" v-for="(item,indexx) in list" :key="indexx"
					@click="$my.go('/myPackageA/goodsAndFacton/store?store_id='+item.id)">
					<view class="li_top">
						<u-image :src="item.store_image" :lazy-load="true" height="80rpx" width="80rpx" radius='8rpx'>
						</u-image>
						<view class="box_center">
							<view class="title co3 fw6">{{item.store_name}}</view>
							<view class="flex">
								<u-rate gutter="2" count="5" v-model="item.postage_score" :allowHalf='true'
									size='24rpx' :readonly='true' activeColor='#FFC047'
									inactiveColor='rgba(255, 168, 72, 0.2)'>
								</u-rate>
								<text class="score">{{item.postage_score}}分</text>
								<text class="deal co9">已成交{{item.pay_number}}+</text>
							</view>
						</view>
						<view class="box_right">
							<view class="entry fontS24 cof">进店</view>
						</view>
					</view>
					<view class="li_center">
						<u-scroll-list :indicator="false">
							<view v-for="(item, index) in item.product"  class="li_img"  :key="index"
								@click.stop="$my.go('/myPackageA/goodsAndFacton/goodsDetails?id='+item.id)">
								<u-image :src="item.image" width="190rpx" height="190rpx" radius="16rpx"></u-image>
								<view class="money">
									<text class="fontS20">￥</text>
									<text>{{' '+item.price}}</text>
								</view>
							</view>
						</u-scroll-list>
					</view>
					<view class="li_bottom co9 fontS24 flexJBC">
						<view class="">
							<text class="">主营:</text>
							<text class="fontS24" v-for="(text,index) in item.main_business" 
								:key="index">{{text}}<text v-if="index!=item.main_business.length-1" style="margin-left: 10rpx;margin-right: 10rpx;" >|</text></text>
						</view>
					</view>
				</view>
				<!-- <view class="li1 flexCenter" v-for="(item ,indexxx) in list" :key="indexxx"
					@click="$my.go('/myPackageA/goodsAndFacton/store?store_id='+item.id)">
					<view style="width: 200rpx;height: 200rpx;border-radius: 20rpx;">
						<image :src="item.store_image" style="width: 200rpx;height: 200rpx;border-radius: 20rpx;">
						</image> 
					</view>
					<view class="right" style="flex: 1;">
						<view class="li_box flexJBC" >
							<text class="co3 fw7 fontS28">{{item.store_name}}</text>
						</view>
						<view class="li_box">
							<text class="co3 fontS24" v-for=" (ite,inde) in  item.main_business ">
								  <text>{{ite}} </text>
								 <text v-if="inde!=item.main_business.length-1" style="margin: 0 5rpx;"> | </text>
							</text>
							<text class="float co9 fontS20">已成交{{item.pay_number}}</text>
						</view>
						<view class="li_box flex">
							<view class="fontS24 co3" style="margin-right: 10rpx;" v-for="(tag,index) in item.tags" :class="index%2==0?'yellow':'pink'">
								{{tag}} 
							</view>
						</view>
						<view class="li_box">
							<text class="fontS24 co6 elipes2">{{item.store_info}}</text>
						</view>
					</view>
				</view> -->
			</view>
			<!-- menu -->
			<view class="menu" v-show="state">
				<view>
					<view class="li">
						<view class="title co3 fontS28">
							开店时间
						</view>
						<view class="tags">
							<view class="tag ">
								<view class="item fos24 co6 " :class="item.checked==true? 'active':'' "
									v-for="(item,index) in years" :key="index" @click="check(item,0)">
									{{item.year}}
								</view>

							</view>
						</view>
					</view>
					<view class="li">
						<view class="title co3 fontS28" style="margin-top: 20rpx;">
							成交量
						</view>
						<view class="tags">
							<view class="tag">
								<view class="item fos24 co6" :class="item.checked==true? 'active':'' "
									v-for="(item,index) in deals" :key="index" @click="check(item,1)">
									{{item.name}}
								</view>
							</view>
						</view>
					</view>
					<view class="btns flexJBC">
						<view @click="replay" class="btnC fw5 fontS24 co9  " >重置</view>
						<view @click="submit" class="btnC fw5 fontS24 sure homeRed  " >确定</view>
					</view>
				</view> 
			</view>
			<view class="model" v-if="ismodel" @click="ismodel=fasle,state=false">
			</view>
		</view>
		<!-- 加载页 -->
		<u-loading-page loading-text="loading..." v-if='pageLoading' :loading='true' bgColor='#f5f5f5'></u-loading-page>
		<view  v-if="(list.length==0) && (!pageLoading)">
			<u-empty width='162px' height="140px" :show='true' customStyle="background:#f5f5f5;padding-top:30%"></u-empty> 
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				pageLoading: true,
				tabLis: '', //当前分类
				value: '', //input值
				show: false,
				state: false,
				page: '1',
				limit: '10',
				ismodel: false,
				list: [], //工厂列表
				isyear: '', //选中的年限
				isdeal: '', //选中的销量
				deals: [{
						name: '0~5k',
						num: '0,5000',
						index: 0,
						checked: false
					},
					{
						name: '5k~1w',
						num: '5000,10000',
						index: 1,
						checked: false
					},
					{
						name: '1w~2w',
						num: '10000,20000',
						index: 2,
						checked: false
					},
					{
						name: '2w~4w',
						num: '20000,40000',
						index: 3,
						checked: false
					},
					{
						name: '4w+',
						num: '40000',
						index: 4,
						checked: false
					},
				],
				years: [{
						year: '小于1年',
						num: '0,1',
						index: 0,
						checked: false
					},
					{
						year: '1~2年',
						num: '1,2',
						index: 1,
						checked: false
					},
					{
						year: '2~3年',
						num: '2,3',
						index: 2,
						checked: false
					},
					{
						year: '3~4年',
						num: '3,4',
						index: 3,
						checked: false
					},
					{
						year: '4年以上',
						num: 4,
						index: 4,
						checked: false
					},
				],
				list1: [],
			}
		},
		methods: {
			// 列表
			submit() {
				// merchantStore/getStore
				this.$my.post('/index/merchantStore/getStore', {
					page: this.page,
					limit: this.limit,
					year: this.isyear,
					number: this.isdeal,
					search_key: this.value,
					type_id: this.tabLis,
				}).then(res => {
					this.pageLoading = false;
					if (res.code == 200) {
						this.ismodel = false
						this.list = res.data.data
						this.state = 0
					}
				})
			},
			// 重置
			replay() {
				this.deals.forEach(item => {
					item.checked = false
				})
				this.years.forEach(item => {
					item.checked = false
				})
				this.isdeal = ''
				this.isyear = ''

				this.page = 1;
				this.list = [];
				this.submit()
			},
			// input框
			change(e) {
				this.value = e
				this.page = 1;
				this.list = [];
				this.submit()
				console.log('change', e);
			},
			// 点击分类
			click(item) {
				console.log('item', item);
				// this.state = item.id
				this.tabLis = item.id;
				this.page = 1;
				this.list = [];
				this.submit();
			},
			isshow() {
				this.state = !this.state
				this.ismodel = !this.ismodel
			},
			// 点击筛选
			check(item, type) {
				this.page = 1;
				this.list = [];
				if (type == 0) {
					this.years.forEach((item) => {
						item.checked = false
					})
					item.checked = true
					this.isyear = item.num
				} else if (type == 1) {
					this.deals.forEach((item) => {
						item.checked = false
					})
					item.checked = true
					this.isdeal = item.num
				}
			},
		},
		onLoad() {
			// 分类菜单
			this.$my.post('/index/merchantStore/getFactoryCategory').then(res => {
				if (res.code == 200) {
					this.list1.push(...res.data.data)
					this.tabLis = this.list1[0].id
					this.submit();
				}
			})
		}
	}
</script>

<style lang="scss" scoped>
	// /deep/.u-fade-enter-active{
	// 	position: absolute !important;
	// 	 height: 100vh !important;
	// 	 top: 337px !important;
	// }
	// .warp {
	// 		display: flex;
	// 		align-items: center;
	// 		justify-content: center;
	// 		// height: 100%;

	// 	}





	.model {
		width: 100%;
		height: 30vh;
		top: 0px;
		position: relative;

		background-color: rgba(0, 0, 0, .6);
	}

	.content {
		.top {
			background-color: #4399FF;
			padding: 0 4%;
		}

		.container {
			background-color: rgb(245, 245, 245);

			.shop_2 {
				border: 2rpx solid transparent;
				.li {
					margin: 0 auto;
					width: 90%;
					// height: 370rpx;
					background-color: white;
					margin-top: 24rpx;
					border-radius: 16rpx;
					padding: 20rpx;
					box-sizing: border-box;
				
					.li_top {
						height: 80rpx;
						display: flex;
				
				
						.box_center {
							height: 100%;
							flex-grow: 1;
							// background-color: pink;
							margin: 0 20rpx;
				
							.score {
								color: #FFA848;
								margin-left: 8rpx;
							}
							.deal {
								margin-left: 20rpx;
							}
						}
				
						.box_right {
							.entry {
								width: 96rpx;
								height: 48rpx;
								padding: 0;
								line-height: 48rpx;
								color: $red !important;
								border: 2rpx solid $red;
								text-align: center;
								border-radius: 24rpx;
							}
						}
					}
				
					.li_center {
						height: 190rpx;
						// background-color: red;
						padding-top: 20rpx;
						padding-bottom: 12rpx;
				
						.li_img {
							min-width: 190rpx;
							height: 190rpx;
							margin-right: 18rpx;
							border-radius: 8rpx;
							overflow: hidden;
							position: relative;
				
							.money {
								position: absolute;
								padding: 0 5rpx;
								height: 36rpx;
								background-color: rgba(0, 0, 0, 0.6);
								border-radius: 20rpx 0 0 0;
								right: 0;
								bottom: 0;
								color: white;
							}
						}
					}
				
					.li_bottom {
				
						// height: 40rpx;
						// background-color: tomato;
						.li_text {
							padding: 0 8rpx;
						}
				
						.border {
							display: inline-block;
							border-left: 2rpx solid #999999;
							border-right: 2rpx solid #999999;
						}
					}
				}

				.li1 {
					margin: 0 auto;
					width: 90%;
					height: 240rpx;
					background-color: white;
					margin-top: 24rpx;
					border-radius: 16rpx;
					padding: 20rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: space-between;


					.right {
						flex-grow: 1;
						margin-left: 20rpx;
						// background-color: tomato;
						height: 200rpx;
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						.li_box {
							.float {
								float: right;
							}

							.yellow {
								margin-top: 10rpx;
								background-color: #FFF2D0;
								padding: 0 8rpx;
								margin-right: 20rpx;
								border-radius: 4rpx;
							}

							.pink {
								margin-top: 10rpx;
								background-color: #FFDED3;
								padding: 0 8rpx;
								border-radius: 4rpx;
							}
						}
					}
				}
			}

			.menu {
				padding: 30rpx;
				background-color: white;

				.li {
					.title {
						margin-bottom: 24rpx;
						// background-color: tomato;
						line-height: 40rpx;
					}

					.active {
						border: 2rpx solid $red !important;
						color: $red;
					}

					.tags {
						.tag {
							overflow: hidden;

							.item {
								border-radius: 8rpx;
								float: left;
								width: 210rpx;
								height: 72rpx;
								background-color: #f5f5f5;
								margin-right: 28rpx;
								margin-bottom: 24rpx;
								text-align: center;
								line-height: 72rpx;
								border: 2rpx solid transparent;
								box-sizing: border-box;
							}

							.item:nth-child(3) {
								margin-right: 0rpx;
							}
						}
					}
				}

				.btns {
					width: 380rpx;
					margin: 20rpx auto 0;
					text-align: center;
					
					.btnC {
						width: 160rpx;
						height: 60rpx;
						line-height: 60rpx;
						border-radius: 30rpx;
						border: 2rpx solid #999999 ;
						background-color: #fff ;
					}
					.sure {
						border: 2rpx solid $red !important;
					}
				}

			}

		}
	}
</style>
